<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function todaySchedule(){
		window.location.href = "./scheduleManage.do";
		window.location.target = "main";
	}
	
	function weekSchedule(){
		window.location.href = "./scheduleManage.do?action=weekSchedule";
		window.location.target = "main";
	}
	
-->
</script>
</head>
<body>
	<table class="table_frame2">
		<tr>
			<td>
				<table class="table_title3">
					<tr>
						<td>
							<button class="btn_schedule2" onclick="todaySchedule()" hidefocus="true">天</button>
							<button class="btn_schedule2" onclick="weekSchedule()" hidefocus="true">周</button>
							<button class="btn_schedule1" onclick="" hidefocus="true">月</button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<div style="width:100%;height:420px;overflow-x: hidden;overflow-y: scroll;border: solid 1px #8FBECA;">
				<table class="table_schedule">
					<tr>
						<td class="title" width="15%"></td>
						<td class="title" width="12%">时间</td>
						<td class="title" width="12%">销售代表</td>
						<td class="title" width="12%">联系方式</td>
						<td class="title">客户名称</td>
					</tr>
					<c:forEach var="dateRecord" items="${monthSchedules}">
					
					<c:choose>
						<c:when test="${fn:length(dateRecord.saleRecords) > 0}">
							<c:forEach var="record" items="${dateRecord.saleRecords}" begin="0" end="0">
							<tr>
								<td rowspan="${fn:length(dateRecord.saleRecords)}">
									<fmt:formatDate value="${dateRecord.date}" pattern="yyyy年MM月dd日"/><br>
									<fmt:formatDate value="${dateRecord.date}" pattern="EEEE"/>
								</td>
								<td class="title">
								<c:choose>
									<c:when test="${record.contactTime == 1 || record.nextContactTime == 1}">上午</c:when>
									<c:when test="${record.contactTime == 2 || record.nextContactTime == 2}">下午</c:when>
								</c:choose>
								</td>
								<td>${record.createPerson}</td>
								<td>
									<c:forEach var="contactWay" items="${contactWays}">
										<c:if test='${record.contactWayId == contactWay.id}'>${contactWay.rangeValue}</c:if>
									</c:forEach>
								</td>
								<td align="left"><a href="./customerManage.do?action=customerDetail&customerId=${record.customerId}&sign=141" target="main">${record.customerName}</a></td>
							</tr>
							</c:forEach>
							<c:forEach var="record" items="${dateRecord.saleRecords}" begin="1">
							<tr>
								<td class="title">
								<c:choose>
									<c:when test="${record.contactTime == 1 || record.nextContactTime == 1}">上午</c:when>
									<c:when test="${record.contactTime == 2 || record.nextContactTime == 2}">下午</c:when>
								</c:choose>
								</td>
								<td>${record.createPerson}</td>
								<td>
									<c:forEach var="contactWay" items="${contactWays}">
										<c:if test='${record.contactWayId == contactWay.id}'>${contactWay.rangeValue}</c:if>
									</c:forEach>
								</td>
								<td align="left"><a href="./customerManage.do?action=customerDetail&customerId=${record.customerId}&sign=141" target="main">${record.customerName}</a></td>
							</tr>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<tr>
								<td rowspan="2">
									<fmt:formatDate value="${dateRecord.date}" pattern="yyyy年MM月dd日"/><br>
									<fmt:formatDate value="${dateRecord.date}" pattern="EEEE"/>
								</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td align="left">&nbsp;</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td align="left">&nbsp;</td>
							</tr>
						</c:otherwise>
					</c:choose>
					
					</c:forEach>
				</table>
				</div>
			</td>
		</tr>
	</table>
</body>
</html>